package com.itheima.chapter03.mapper;

import com.itheima.chapter03.domain.Comment;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CommentMapper2 {
    @Select("SELECT * FROM t_comment WHERE id = #{id}")
    Comment findById(Integer id);

    @Select("SELECT * FROM t_comment WHERE a_id = #{aId}")
    List<Comment> selectCommentArticleId(Integer aId);

    @Insert("INSERT INTO t_comment (content, author, a_id) VALUES (#{content}, #{author}, #{aId})")
    int insertComment(Comment comment);

    @Update("UPDATE t_comment SET content = #{content}, author = #{author}, a_id = #{aId} WHERE id = #{id}")
    int updateComment(Comment comment);

    @Delete("DELETE FROM t_comment WHERE id =#{id}")
    int deleteComment(Integer id);
}
